import re


def test_search():
    pattern = r"\d{2}"
    source = "I am 25 years ols."

    result = re.search(pattern=pattern, string=source)

    print(result.group())


def test_match():
    pattern = r"\d{2}"
    source = "25 years old."

    result = re.match(pattern=pattern, string=source)
    print(result)


def test_fullmatch():
    pattern = r"\d{2}"
    source = "25"

    result = re.fullmatch(pattern=pattern, string=source)
    print(result)


def test_findall():
    pattern = r"\d{2}"
    source = "25 06 sadb asd899"

    result = re.findall(pattern=pattern, string=source)
    print(result)


def test_finditer():
    pattern = r"\d{2}"
    source = "25 06 sadb asd899"

    result = re.finditer(pattern=pattern, string=source)
    for rs in result:
        print(rs.group())


def test_compile():
    pattern_str = r"\d{2}"
    pattern = re.compile(pattern_str)
    source = "25 06 sadb asd899"
    result = pattern.findall(string=source)
    print(result)


if __name__ == '__main__':
    # test_search()
    # test_match()
    # test_fullmatch()
    # test_findall()
    # test_finditer()

    test_compile()
